package ru.kest.torrentwatchlist.parsing;

import org.springframework.beans.factory.annotation.Autowired;
import ru.kest.torrentwatchlist.dao.MovieDAO;

import java.util.List;

/**
 * Created by kkharitonov on 27.11.2014.
 */
public class ParsingService {

    @Autowired
    private MovieDAO movieDAO;

    private List<TorrentCollector> torrentCollectors;

    public ParsingService(List<TorrentCollector> torrentCollectors) {
        this.torrentCollectors = torrentCollectors;
    }

    public int parseAll() {
        int count = 0;
        // TODO replace to multithreading implementation
        for(TorrentCollector p : torrentCollectors) {
            count += p.parse();
        }

        return count;
    }

    public void removeAll() {
        movieDAO.removeAll();
    }
}
